package com.ereach;

import java.util.LinkedList;

public class DemoLinkedList {
    public static void main(String[] args) {
        LinkedList<String> list1 = new LinkedList<>();

        list1.add("Lion");
        list1.add("Dog");
        list1.add("Tiger");
        list1.add("Bird");
        list1.add("Fish");

        System.out.println(list1);

        System.out.println("add element to linkedlist specified position");
        list1.add(3, "Bug");
        System.out.println(list1);

        System.out.println("add element to linkedlist first position");
        list1.addFirst("Dophin");
        System.out.println(list1);

        System.out.println("add element to linkedlist last position");
        list1.addLast("BabyDog");
        System.out.println(list1);
    }
}
